package org.itboys.core.service.mongo.web;

import org.itboys.core.common.SundayCommonConstants;
import org.itboys.core.entity.mongo.SundayWeatherRecord;
import org.itboys.mongodb.core.MongoDataSource;
import org.itboys.mongodb.service.BaseMongoService;
import org.itboys.param.PageResult;
import org.itboys.param.ParamUtil;
import org.springframework.stereotype.Service;

import javax.annotation.Resource;
import javax.servlet.http.HttpServletRequest;
import java.util.Map;

/**
 * Auther: 罗尧坤
 * Date: 2018/8/21
 * Description:
 */
@Service
public class SundayWeatherRecordService extends BaseMongoService<SundayWeatherRecord> {

    @Resource(name = "mobileDs")
    private MongoDataSource mongoDataSource;
    @Override
    protected MongoDataSource getMongoDataSource() {
        return mongoDataSource;
    }
    @Override
    protected Class<SundayWeatherRecord> getEntityClass() {
        return SundayWeatherRecord.class;
    }

    /**
     * 查询所有天气记录
     * @param request
     * @return
     */
    public PageResult<SundayWeatherRecord> select(HttpServletRequest request){
        Map<String, Object> param = ParamUtil.packageMongoExactParam(request);
        param.put("isDeleted", SundayCommonConstants.NO);
        PageResult<SundayWeatherRecord> result = super.pageQuery(request, param);
        return result;
    }

}
